#ifndef __MODEL_H__
#define __MODEL_H__

#include <vector>
#include <time.h>
#include "PlayerModel.h"
#include "Card.h"


class GameModel
{
private:
  static const int SHUFFLE_TIME_;
  //number of players
  int playersNumber_;

  //shows who is winner. If 0 then noone
  int whoIsWinner_;

  //shows if game started or not
  bool isGameStarted_;
  
  bool duelStarted_;

  //number of player which have turn
  int currentTurn_;
  
  int arrowsInsideFlag_;

  //array of players. 0 is for Totem
  std::vector<PlayerModel> players_;

  std::vector<Card> cards_;
  
  int getTurn();
  int findWinner();
  void shuffle();
  void distribute();
  void zeroDuelists();
  
  int duelWinner_;
  int duelLooser_;
  int wrongDuelist_;
public:

  static const int MAX_PLAYERS_NUM_;
  static const int CARDS_NUM_;
  static const int USUAL_CARDS_NUM_;
  static const int ARROWS_INSIDE_CARDS_NUM_;
  static const int EVERY_CARD_TYPE_NUM_;
  static const int ARROWS_INSIDE_ID_;
  
  GameModel();



  //add new player to the table. Returns player's seat
  int addPlayer(const std::string &name, const time_t &connectTime, int &error);

  //player opens card
  int openCard(int playerNum);

  //some of players gets totem
  int getTotem(int playerNum);

  //starts game
  int startGame(bool toShuffle);

  //returns number of player's opened cards
  int getOpenedCardsNumber(int playerNum) const;

  //returns number of player's closed cards
  int getClosedCardsNumber(int playerNum) const;

  //returns who is winner
  int getWhoIsWinner() const;

  //returns number of players
  int getPlayersNumber() const;

  bool isGameStarted() const;

  int getCurrentTurn() const;

  int getTopCardID(int seat) const;
  int getTopCardColor(int seat) const;

  //returns player's name
  const std::string& getPlayerName(int seat) const;

  int getArrowsInsideFlag() const; 
  
  const std::vector<Card>& getCards() const;
  void setCards(const std::vector<Card>& cards);

  int getDuelWinner();
  int getDuelLooser();
  int getWrongDuelist();

};
#endif
